# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=dynamips
pkgver=0.2.22
pkgrel=0
pkgdesc="Cisco router emulator"
url="https://github.com/GNS3/dynamips"
arch="all"
license="GPL-2.0"
makedepends="cmake libpcap-dev elfutils-dev linux-headers libnsl-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/GNS3/dynamips/archive/v$pkgver.tar.gz"

prepare() {
	sed -e "s:^set ( DYNAMIPS_FLAGS:#&:" -i cmake/dependencies.cmake
	default_prepare
}

build() {
	if [ $CARCH == x86_64 ]; then
		export DYNAMIPS_ARCH=amd64
	fi
	export CFLAGS="$CFLAGS -Wno-enum-compare"
	export CXXFLAGS="$CXXFLAGS -Wno-enum-compare"
	cmake -B build . \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX:PATH=/usr
	make -C build
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

sha512sums="
fd7327e92ea5d9bb5109f37a405c753ef9dbecf3e48976df292d6fe7ab15a149bf421149f87b060c8ec79a884f291a0258d1cb2f639683c6edb1373d68f948be  dynamips-0.2.22.tar.gz
"
